<template>
  <div class="xtx-home-page">
    <div class="home-entry">
      <div class="container">
        <!-- 左侧分类 -->
        <home-category />
        <!-- 轮播图 -->
        <div class="home-banner">
          <XtxCarousel auto-play :sliders="sliders"></XtxCarousel>
        </div>
      </div>
      <!-- 新鲜好物 -->
      <home-new />
      <!-- 人气推荐 -->
      <home-hot />
      <!-- 热门品牌 -->
      <home-brand />

    </div>
  </div>
</template>

<script>
import HomeCategory from './components/home-category.vue'
import HomeNew from './components/home-new.vue'
import HomeHot from './components/home-hot.vue'
import HomeBrand from './components/home-brand.vue'
import { getBanner } from '@/api/home'
import { onMounted, ref } from 'vue'

export default {
  name: 'xtx-home-page',
  components: { HomeCategory, HomeNew, HomeHot, HomeBrand },
  setup() {
    // 1. 轮播图数据
    const sliders = ref([])
    onMounted(async () => {
      const data = await getBanner()
      sliders.value = data.result
    })

    // 切换数据
    const show = ref(true)

    return { sliders, show }
  }
}
</script>

<style lang="less" scoped>
.xtx-home-page {
  .home-banner {
    width: 1240px;
    height: 500px;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 98;
    // 覆盖轮播图组件样式
    .xtx-carousel {
      width: 100%;
      height: 100%;
      // 子组件看不见的内容（组件内部）
      ::v-deep {
        .carousel-btn.prev {
          left: 270px;
        }
        .carousel-indicator {
          padding-left: 250px;
        }
      }
    }
  }
}
</style>
